package com.css.apps.base.user.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.css.apps.base.common.provider.json.UserJsonProvider;
import com.css.core.configuration.Environment;
import com.css.util.Ajax;
import com.css.util.Messages;
import com.css.util.StringHelper;
import com.css.webbase.webwork.action.AdminAction;
import com.opensymphony.xwork.Action;

@SuppressWarnings("serial")
public class GetUserRoleTree extends AdminAction {

	private static Log log = LogFactory.getLog(GetUserRoleTree.class);
	private String userId;

	@Override
	protected String adminGo() {
		try {
			if (StringHelper.isNotEmpty(userId)) {
				UserJsonProvider ujp = new UserJsonProvider();
				result = ujp.getUserRoleTree(userId).toString();
			}
			return SUCCESS;
		} catch (Exception ex) {
			result = Ajax.JSONResult(Environment.RESULT_CODE_ERROR, Messages.getString("systemMsg.exception"));
			log.error(ex.getMessage(), ex);
			return Action.ERROR;
		}
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

}
